package com.kuaimacode.kframework.admin.services.content;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.kuaimacode.kframework.mybatis.mapper.index.BootstrapImgMapper;
import com.kuaimacode.kframework.mybatis.models.index.BootstrapImg;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@Service
public class BootstrapImgService extends ServiceImpl<BootstrapImgMapper, BootstrapImg> {

    /**
     * 查询广告页/引导页图片
     * @return
     */
    public PageInfo<BootstrapImg> findAll(int pageNum, int pageSize, String notes) {

        PageHelper.startPage(pageNum, pageSize);
        QueryWrapper queryWrapper = new QueryWrapper();
        Optional.ofNullable(notes).ifPresent(str->queryWrapper.like("notes",notes));

        queryWrapper.orderByAsc("status");

        return new PageInfo<BootstrapImg>(baseMapper.selectList(queryWrapper));
    }


    public void updateStatus(String type,String status){


        baseMapper.updateStatus(type,status);
    }




}
